package com.yk.filedownload;

import com.yk.filedownload.ConfigIt.Configuration;
import com.yk.filedownload.DataTransfer.RedisOp.RedisOperation;
import com.yk.filedownload.DataTransfer.RedisOp.impl.RedisOperationImpl;
import com.yk.filedownload.downloader.linstener.ThreadListener;
import com.yk.filedownload.downloader.DownloaderProducer;
import com.yk.filedownload.threadpool.DownloadThreadPool;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Project Name:cykfiledownload
 * File Name:StartMethod
 * Package Name:com.yk.filedownload
 * Date:2017\12\13 0013
 * Author:dengtianjia
 * Description:
 * Copyright (c) 2017, 重庆云凯科技有限公司 All Rights Reserved.
 */
public class StartMethod {

    /**
     * 测试方法
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception{
        RedisOperation redisOperation = new RedisOperationImpl();
        DownloadThreadPool downloadThreadPool= new DownloadThreadPool(Configuration.CORE_POOL_SIZE,Configuration.MAXIMIMPOOLSIZE,Configuration.KEEP_ALIVE_TIME);
        ScheduledThreadPoolExecutor managerPool = new ScheduledThreadPoolExecutor(1);
        DownloaderProducer producer = new DownloaderProducer(downloadThreadPool);
        Runnable listener = new ThreadListener(redisOperation,downloadThreadPool);
        managerPool.scheduleWithFixedDelay(listener,4000,3000, TimeUnit.MILLISECONDS);
        producer.start();

    }

}
